package com.lhy.goods.controller;

import com.lhy.domain.Classify;
import com.lhy.entity.Result;
import com.lhy.goods.service.ClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *分类管理
 */
@RestController
@RequestMapping("/Classify")
public class ClassifyController {
    @Autowired
   private ClassifyService classifyService;
    /**
     * 查询全部分类表
     * @param
     * @return
     */
    @GetMapping("/selectAll")
    public Result<List<Classify>> selectAll(){
        return new Result<>("查询成功",classifyService.selectAll());
    }

/**
     *插入分类数据
     */
    @PostMapping("/insert")
    public Result<Integer> insertClassify(@RequestBody Classify classify){
        Integer i = classifyService.insertClassify(classify);
        if (i == 1){
            return new Result<>("插入成功",i);
        }
        return new Result<>("插入失败",i);
    }
    /**
     *修改分类数据
     */
    @PostMapping("/update")
    public Result<Integer> updateClassify(@RequestBody Classify classify){
        Integer i = classifyService.updateClassify(classify);
        if (i == 1){
            return new Result<>("修改成功",i);
        }
        return new Result<>("修改失败",i);
    }
    /**
     *删除分类数据
     */
    @PostMapping("/delete")
    public Result<Integer> deleteClassify(@RequestParam String ids){
        Integer i = classifyService.deleteClassify(ids);
        if (i == 1){
            return new Result<>("删除成功",i);
        }
        return new Result<>("删除失败",i);
    }
}
